package com.db.williamchart.slidertooltip;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.db.williamchart.Tooltip;

public class SliderTooltip implements Tooltip {

    private View tooltipView;
    private int color = Color.BLACK;

    @Override
    public void onCreateTooltip(ViewGroup parentView) {
        tooltipView =
                LayoutInflater.from(parentView.getContext())
                        .inflate(R.layout.tooltip_layout, parentView, false);
        tooltipView.setBackgroundColor(color);
        tooltipView.setVisibility(View.INVISIBLE);
        parentView.addView(tooltipView);
    }

    @Override
    public void onDataPointTouch(float x, float y) {
        tooltipView.setVisibility(View.VISIBLE);
        tooltipView.setX(x - tooltipView.getWidth() / 2);
    }

    @Override
    public void onDataPointClick(float x, float y) {

    }

    public View getTooltipView() {
        return tooltipView;
    }

    public void setTooltipView(View tooltipView) {
        this.tooltipView = tooltipView;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }
}
